<script>
import BaseEditForm from '../components/baseForm/edit';
export default {
    props: {

    },
    extends: BaseEditForm,
    data () {
        return {}
    },
    methods: {
        submit: function () {
            const { id, parentId, formName } = this;
            this.$f.validate((valid) => {
                if (valid) {
                    const formData = this.formatSubmitData(formName, this.$f.formData());
                    this.$x.post('/userinfo/op/update', {
                        data: {
                            ...formData,
                            id,
                            group_id: parentId
                        }
                    }).then(() => {
                        this.$message.success('编辑成功！');
                        this.$emit('listChanged')
                        this.$router.back();
                    });
                }
            });
        },
        fetchData: function () {
            const { formName, parentName } = this;
            this.$x.get('/userinfo/op/detail', { id: this.id })
                .then(({ data }) => {
                    this.values = this.formatValues(formName, Object.assign({}, data, { group_id: parentName }));
                    this.ready = true;
                });
        }
    }
}
</script>
